package com.indexingsystem.system.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.indexingsystem.boss.Vo.TerminalsVo;
import com.indexingsystem.boss.admin.mapper.TerminalsMapper;
import com.indexingsystem.boss.common.PagedResult;
import com.indexingsystem.boss.entity.Terminals;
import com.indexingsystem.boss.utils.BeanUtils;
import com.indexingsystem.system.service.ITerminalsService;

@Service
public class TerminalsServiceImpl implements ITerminalsService {

	@Resource
	private TerminalsMapper terminalsMapper;

	/**
	 * 通过终端id删除终端信息.
	 */
	@Override
	public int deleteByPrimaryKey(String terminalCode) {
		return terminalsMapper.deleteByPrimaryKey(terminalCode);
	}

	/**
	 * 批量删除终端信息.
	 * 
	 * @param terminalIdList
	 * @return
	 */
	@Override
	public int deleteTerminalsByIdBatch(List<String> terminalIdList) {
		return terminalsMapper.deleteTerminalsByIdBatch(terminalIdList);
	}

	/**
	 * 新增终端信息.
	 */
	@Override
	public int insertSelective(Terminals record) {
		return terminalsMapper.insertSelective(record);
	}

	/**
	 * 通过终端id查询终端信息.
	 */
	@Override
	public Terminals selectByPrimaryKey(String terminalCode) {
		return terminalsMapper.selectByPrimaryKey(terminalCode);
	}

	/**
	 * 通过终端code和终端名称获取终端信息，判断是否存在重复.
	 * 
	 * @param terminalsVo
	 * @return
	 */
	@Override
	public Terminals getTerminalsByTerminalCodeOrTerminalName(TerminalsVo terminalsVo) {
		return terminalsMapper.getTerminalsByTerminalCodeOrTerminalName(terminalsVo);
	}

	/**
	 * 修改终端信息.
	 */
	@Override
	public int updateByPrimaryKeySelective(Terminals record) {
		return terminalsMapper.updateByPrimaryKeySelective(record);
	}

	/**
	 * 分页查询终端信息.
	 */
	@Override
	public PagedResult<Terminals> selectTerminalsList(String queryCriteria,Integer pageNo, Integer pageSize) {
		pageNo = pageNo == null ? 1 : pageNo;
		pageSize = pageSize == null ? 10 : pageSize;
		// startPage是告诉拦截器说我要开始分页了。分页参数是这两个。
		PageHelper.startPage(pageNo, pageSize);
		return BeanUtils.toPagedResult(terminalsMapper.selectTerminalsList(queryCriteria));
	}

	/**
	 * 获取终端下拉列表.
	 * 
	 * @return
	 */
	@Override
	public List<Terminals> getTerminalsDropList() {
		return terminalsMapper.selectTerminalsList(null);
	}

	/**
	 * 获取终端总数量.
	 */
	@Override
	public Integer getTerminalsCount(String queryCriteria) {
		return terminalsMapper.getTerminalsCount(queryCriteria);
	}

    @Override
    public List<Terminals> getTerminalsByTerminalId(String terminalId)
    {
        return terminalsMapper.getTerminalsByTerminalId(terminalId);
    }
    
    @Override
    public   List<Terminals>  getTerminalsByTerminalList(){
    	return  terminalsMapper.getTerminalsByTerminalList();
    }
    
}